<template>
	<view class="goodsPage">
		<!-- <view class="goodsImgBox">
			<imageSwiper class="goodsImg" :previewImage="true" :imgs="dataInfo.picture"></imageSwiper>
		</view> -->
		<uni-nav-bar height="88rpx" fixed title="社区资讯详情" color="#000000" :border="false" left-icon="left"
			@clickLeft="$back" statusBar>
		</uni-nav-bar>
		<view class="activityInfoContent">
			<view class="activityInfoTitle">{{dataInfo.noticeTitle}}</view>
			<view class="timeBox">
				<view class="activityInfoTime">
					<view style="padding: 4rpx 8rpx; margin-right: 8rpx; background-color: #e0e2e4; border-radius: 8rpx;">作者</view>
					<view>
						<!-- {{dataInfo.createBy}} -->
						{{dataInfo.createTime}}
					</view>
				</view>
				<view class="left"></view>
			</view>
			<view class="goodsDescribe">
				<mp-html :content="dataInfo.noticeContent" />
			</view>
			<!-- <view class="likeButtonBox">
				<view class="likeButton" :class="{on:dataInfo.like}">
					<uni-icons type="hand-up-filled" size="60rpx" :color="dataInfo.like?'#f74851':'#999999'"
						@click="setLike"></uni-icons>
				</view>
				<view class="likeNum">{{dataInfo.likeNum}}</view>
			</view> -->
		</view>
		<view style="height: 120rpx;"></view>	<!-- blank -->
		<view class="likeButtonBox">
			<view style="display: flex; margin-left: 24rpx; align-items: center;">
				<image src="@/static/activity/activityScore.png" style="width: 36rpx; height: 36rpx; margin-right: 12rpx;"></image>
				<view>{{dataInfo.integral}}积分</view>
			</view>
			<view style="display: flex; align-items: center; margin-right: 24rpx;">
				<view class="likeButton" :class="{on:dataInfo.like}">
					<uni-icons type="hand-up-filled" size="60rpx" :color="dataInfo.like?'#f74851':'#999999'"
						@click="setLike"></uni-icons>
				</view>
				<view class="likeNum">{{dataInfo.likeNum}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as noticeApi from "@/api/notice.js"
	import * as systemApi from "@/api/system.js"
	import * as likeApi from "@/api/like.js"
	export default {
		data() {
			return {
				infoId: '',
				dicts: {
					elite_type: [],
					event_type: [],
					policy: {}
				},
				userInfo: {},
				dataInfo: {
					createBy: "admin",
					createTime: "2024-02-20 16:12:07",
					elieType: "0",
					isPublic: 0,
					policyFile: "http://192.168.1.105:8087/dev-api/profile/upload/2024/02/20/xxxxxxx_20240220161203A001.pdf",
					policyId: 2,
					policyName: "测试政策",
					policyType: 2,
					remark: "xxxx",
					source: "政策来源",
					updateBy: null,
					updateTime: "2024-02-29 10:17:49",
				}
			};
		},
		onLoad(options) {
			console.log(options);
			this.infoId = options.id
			this.getInfo()
			this.getDictDataList('policy')
		},
		onShow() {
			this.$store.dispatch('userBaseInfo').then(res => {
				this.userInfo = res.user
				console.log(res);
			})
		},
		methods: {
			setLike() {
				if (this.dataInfo.like) {
					return
				}
				const params = {
					userId: this.userInfo.userId,
					noticeId: this.dataInfo.noticeId
				}
				likeApi.addlike(params).then(res => {
					this.$toast('点赞成功')
					this.getInfo()
				})
			},
			getDictDataList(dictType) {
				systemApi.dictDataList(dictType).then(res => {
					let objs = {}
					res.rows.forEach((item) => {
						objs[item.dictValue] = item.dictLabel
					})
					this.dicts[dictType] = objs

				})
			},
			getInfo() {
				noticeApi.noticeId(this.infoId).then(({
					data
				}) => {
					this.dataInfo = data
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	@import "@/utils/viewScss/info.scss";

	.likeButtonBox {
		// display: flex;
		// flex-direction: column;
		// align-items: center;
		// justify-content: center;
		// padding: 20rpx 0;

		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -8rpx 8rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 30rpx;
		
		.likeNum {
			font-size: 30rpx;
		}
		
		.likeButton {
			// border: 2rpx solid #9999;
			// border-radius: 50%;
			// box-sizing: border-box;
			// padding: 10rpx;
			// margin-bottom: 10rpx;
		
			// &.on {
			// 	border: 2rpx solid #f74851
			// }
		}
	}

	.goodsPage {
		.timeBox {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 30rpx;

			.left {
				display: flex;
				align-items: center;

			}

			.activityInfoTime {
				display: flex;
				align-items: center;
				margin-bottom: 0;
				font-size: 24rpx;
			}
		}

		.sourceText {
			margin-right: 8rpx;
			font-size: 28rpx;
		}

		.informationType {
			margin-left: 8rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 20rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			padding: 0 10rpx;
			color: #01CE16;
			height: 36rpx;
			background: rgba(1, 206, 22, 0.1);
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			border: 1rpx solid #01CE16;
		}
	}
</style>